package sr.myserver.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.springframework.util.StringUtils;

@Data
@TableName(value = "sys_menus")
@ApiModel(value = "菜单信息", description = "菜单信息")
public class SysMenus extends BaseEntity implements Comparable<SysMenus>, java.io.Serializable {

    @TableId(value = "id", type = IdType.ASSIGN_ID)
    @Schema(description = "菜单主键")
    private String id;

    @Schema(description = "菜单名称")
    private String title;

    @Schema(description = "菜单地址")
    private String url;

    @Schema(description = "显示图标")
    private String icon;

    @Schema(description = "上级菜单编号")
    private String superId;

    @Schema(description = "支持按钮编号,多个以,号分隔")
    private String btnId;

    @Schema(description = "排序编号")
    private String menuOrder;

    @Override
    public int compareTo(SysMenus o) {
        if (!StringUtils.hasLength(this.getMenuOrder())) {
            return 1;
        }
        if (!StringUtils.hasLength(o.getMenuOrder())) {
            return -1;
        }
        if (Integer.parseInt(menuOrder) > Integer.parseInt(o.getMenuOrder())) {
            return 1;
        } else if (Integer.parseInt(menuOrder) == Integer.parseInt(o.getMenuOrder())) {
            return 0;
        } else {
            return -1;
        }
    }
}
